home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / TSPA3260.ZIP / TSUNTI.INT < prev    next >
Text File  |  1992-06-13  |  4KB  |  91 lines

  1. {$B-,D-,F-,I+,N-,R-,S+,V+}
  2.  
  3. (*
  4. Timo Salmi UNiT I
  5. A Turbo Pascal unit for putting infomation into the program's .exe file
  6. and retrieving .exe file information
  7. All rights reserved 1-Aug-90
  8. Updated 8-Aug-90
  9.  
  10. This unit may be used and distributed freely for PRIVATE, NON-COMMERCIAL,
  11. NON-INSTITUTIONAL purposes, provided it is not changed in any way. For
  12. ANY other usage, such as use in a business enterprise or a university,
  13. contact the author for the terms of registration.
  14.  
  15. The units are under development. Comments and contacts are solicited. If
  16. you have any questions, please do not hesitate to use electronic mail for
  17. communication.
  18. InterNet address: ts@chyde.uwasa.fi         (preferred)
  19. Funet address:    GADO::SALMI
  20. Bitnet address:   SALMI@FINFUN
  21.  
  22. The author shall not be liable to the user for any direct, indirect or
  23. consequential loss arising from the use of, or inability to use, any unit,
  24. program or file howsoever caused. No warranty is given that the units and
  25. programs will work under all circumstances.
  26.  
  27. Timo Salmi
  28. Professor of Accounting and Business Finance
  29. Faculty of Accounting & Industrial Management; University of Vaasa
  30. P.O. BOX 297, SF-65101 Vaasa, Finland
  31. *)
  32.  
  33. unit TSUNTI;
  34.  
  35. (* ======================================================================= *)
  36.                           interface
  37. (* ======================================================================= *)
  38.  
  39. uses Dos
  40.      {$IFDEF VER40}  (* To provide what TP 4.0 is missing *)
  41.      ,TSUNT45        (* as compared to TP 5.0 and TP 5.5 *)
  42.      {$ENDIF}
  43.      ;
  44.  
  45. (* ====================================================================
  46.                     Write / read the .exe file
  47.    ==================================================================== *)
  48.  
  49. (* This procedure returns the number of times the program has been called.
  50.    It also returns an error status string. In case of success the status
  51.    string is empty, that is ''. The procedure works by saving the count
  52.    into your compiled .exe file. The counter is initialized to 0 every
  53.    time when you (re)compile your program. Note that after calling USECOUNT
  54.    {$I+} will have been turned on. Making the .exe file readonly will
  55.    invoke an error status. *)
  56. procedure USECOUNT (var TimesCalled : longint;
  57.                     var status      : string);
  58.  
  59. (* Here is a faster and more general alternative to USECOUNT. This one is,
  60.    however, much more difficult to use since you have to provide it the
  61.    necessary information all youself. Study the example test in TSUNTI.TST
  62.    carefully and experiment to get the hang of it. Does not work for
  63.    MsDos versions earlier than 3. For earlier versions does nothing.
  64.    Be very careful to give the correct size of your variable (SizeOfVariable)
  65.    to the routine. Record variables are allowed, so you can pass on large
  66.    amounts of information in the .exe. *)
  67. procedure BRANDEXE
  68.   (var Variable;               (* any type of variable information *)
  69.    SizeOfVariable : word;      (* give the size of your variable *)
  70.    var status     : word);     (* returns 0 if successfull *)
  71.  
  72. (* This function calculates the direct chekcsum of your program's .exe
  73.    file when you include this function in your program. The trick is
  74.    that the var Variable (which can be of any type) is not included
  75.    in the checksum. Thus the Variable can contain any prerecorded
  76.    information such as what the checksum should be. Be very careful to
  77.    give the correct size of your variable (SizeOfVariable) to the routine.
  78.    Record variables are allowed. The function requires at least Dos version
  79.    3.0, TP version 5.0 or 5.5, and a heap of about 12000 bytes. If the
  80.    checksum calculation cannot be performed fails, chksumfn returns 0.
  81.  
  82.       Study TSUNTI.TST TEST4 carefully for the correct usage
  83.  
  84.    *)
  85. function CHKSUMFN
  86.   (var Variable;               (* any type of variable information *)
  87.    SizeOfVariable : word)      (* give the size of your variable *)
  88.      : longint;
  89.  
  90.  
  91.